<?php
App::uses('AppController', 'Controller');
/**
 * News Controller
 */
class CareersController extends AppController {

    public $uses = array('Career', 'Article');

/**
 * Components
 *
 * @var array
 */
	public $components = array('Paginator');
    public $paginate = array(
        'limit' => 12,
        'order' => array(
            'Career.created_date' => 'DESC'
        )
    );
/**
 * index method
 *
 * @return void
 */
	public function index() {
		$this->Career->recursive = -1;
        $this->set('career', $this->Career->find('first'));
        //$this->Paginator->settings = $this->paginate;
		//$this->set('careers', $this->Paginator->paginate('Career'));
        $cond = array('conditions' => array('category_id' => 1), 'order' => 'created_date DESC', 'limit' => 5);
        $this->set('articleLastest', $this->Article->find('all', $cond));
		$this->set('id', 5);
	}
    
/**
 * view method
 *
 * @throws NotFoundException
 * @param string $id
 * @return void
 */
	public function detail($id = null) {
		if (!$this->Career->exists($id)) {
			throw new NotFoundException(__('Invalid Career'));
		}
		$options = array('conditions' => array('Career.' . $this->Career->primaryKey => $id));
		$this->set('career', $this->Career->find('first', $options));
        
        $this->Career->recursive = -1;
        $cond = array('conditions' => array('Career.' . $this->Career->primaryKey . ' <>' => $id, 'category_id' => 1), 'order' => 'created_date DESC', 'limit' => 5);
        $this->set('careerLastest', $this->Career->find('all', $cond));
	}
	
}
